<?php 
$show_validator = true;
include TMPL_PATH.'public/header.phtml';
?>
<script type="text/javascript" src="/statics/xheditor/xheditor-zh-cn.min.js"></script>
<script type='text/javascript' src="/statics/js/swfupload/swfupload.js"></script>
<script type='text/javascript' src="/statics/js/swfupload/swfupload.queue.js"></script>
<script type="text/javascript" src="/statics/js/swfupload/fileprogress.js"></script>
<script type="text/javascript" src="/statics/js/swfupload/handlers.js"></script>

<link rel="stylesheet" type="text/css" href="/statics/js/calendar/jscal2.css"/>
<link rel="stylesheet" type="text/css" href="/statics/js/calendar/win2k.css"/>
<script type="text/javascript" src="/statics/js/calendar/calendar.js"></script>
<script type="text/javascript" src="/statics/js/calendar/lang/zh-cn.js"></script>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
        <a href='<?php echo U('product/designer_product');?>' ><em>作品列表</em></a><span>|</span>
        <a href='javascript:;' class="on"><em>升级作品</em></a>
		</div>
</div>
<script type="text/javascript"> 
<!--
	$(function(){
		$.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}});
		$("#catid").formValidator({onshow:"请选择分类",onfocus:"请选择分类",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请选择分类"});
		<?php 
			//	if(isset($languageList) && $languageList):
			//		foreach ($languageList as $language_id => $language_name):
			?>
			//		var language_name = "<? echo $language_name; ?>";
			//		var language_id = <?php echo $language_id;?>;
//					$("#product_name_"+language_id).formValidator({onshow:"请输入"+language_name+"产品名称",onfocus:"请输入"+language_name+"产品名称",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请输入"+language_name+"产品名称"});
					$("#product_name_1").formValidator({onshow:"请输入产品名称",onfocus:"请输入产品名称",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请输入产品名称"});		
	});

//-->
</script>
<style type='text/css'>
.pic {
    float: left;
    margin-right: 10px;
    text-align: center;
}
.pic img {
    border: 3px solid #EFEFED;
    cursor: pointer;
}
.pic img.current {
    border: 3px solid #FF6600;
}
</style>
<form name="myform" id="myform" action="__SELF__" method="post" enctype="multipart/form-data">
<input type="hidden" id="related_info" name="related_info" value="<?php echo (isset($productsRelatedList) && $productsRelatedList) ? strtr(json_encode($productsRelatedList), '"', '\''):'{}';?>">
<div class="pad-10">
<div class="col-tab">
<ul class="tabBut cu-li">
<?php 
$base_tab = 4;
$langCount = 0;
if(isset($languageList) && $languageList){
		$langCount = count($languageList);
}
$langCount += $base_tab;
?>
<li id="tab_setting_1" class="on" onclick="SwapTab('setting','on','',<?php echo $langCount;?>,1);">基本选项</li>
<li id="tab_setting_2" onclick="SwapTab('setting','on','',<?php echo $langCount;?>,2);">扩展属性</li>
<!--<li id="tab_setting_3" onclick="SwapTab('setting','on','',<?php echo $langCount;?>,3);">商品批发</li>-->
<li id="tab_setting_3" onclick="SwapTab('setting','on','',<?php echo $langCount;?>,3);">产品相关联</li>
<li id="tab_setting_4" onclick="SwapTab('setting','on','',<?php echo $langCount;?>,4);">商品尺码</li>
<?php 
$i = $base_tab+1;
	if(isset($languageList) && $languageList):
		foreach ($languageList as $language_id => $language_name):
	?>
<li id="tab_setting_<?php echo $i;?>" onclick="SwapTab('setting','on','',<?php echo $langCount;?>,<?php echo $i;?>);"><?php echo $language_name;?></li>
<?php
		$i++;
		endforeach;
	endif;
	?>

</ul>
<div id="div_setting_1" class="contentList pad-10">
<table width="100%" class="table_form ">
      <tr>
        <th width="100">产品分类：</th>
        <td>
		<select name="catid" id="catid">
		<option value='0'>≡ 作为一级分类 ≡</option>
		<?php echo $select_categorys;?>
		</select>		</td>
      </tr>
<!--      <tr>
            <th>扩展分类：</th>
            <td>
              <input type="button" class="button" onclick="addOtherCat(this.parentNode)" value="添加">
              <?php if(isset($other_cat_list) && $other_cat_list):
              	foreach ($other_cat_list as $other):
              ?>
              <select name="other_cat[]">
              	<option value='0'>≡ 作为一级分类 ≡</option>
              	<?php echo $other;?>
              </select>
              <?php endforeach;endif;?>
            </td>
          </tr>
       <tr>
        <th>品牌：</th>
        <td>
				 <select name="brand_id" id="brand_id">
				 	<option value='' selected>请选择品牌</option>
				 	<?php 
				 	if (isset($brandList) && $brandList):
				 		foreach ($brandList as $key => $val):
				 	?>
				 	<option value='<?php echo $key?>' <?php if(isset($product['brand_id']) && $key==$product['brand_id']) echo 'selected';?>><?php echo $val;?></option>
				 	<?php 
				 		endforeach;
				 	endif;
				 	?>
				 </select>
				</td>
      </tr>
      <?php if(isset($suppliersList) && $suppliersList):?>
      <tr>
        <th> 选择供货商：</th>
        <td>
				 <select id="suppliers_id" name="suppliers_id">
        <option value="0">不指定供货商属于本店商品</option>
				 	<?php 
				 		foreach ($suppliersList as $key => $val):
				 	?>
				 	<option value='<?php echo $key?>' <?php if(isset($product['suppliers_id']) && $key==$product['suppliers_id']) echo 'selected';?>><?php echo $val;?></option>
				 	<?php 
				 		endforeach;
				 	?>
				 </select>
				</td>
      </tr>
     <?php endif;?> -->
     <?php if(isset($designerList) && $designerList):?>
      <tr>
        <th> 选择设计师：</th>
        <td>
				 <select name="designer_id">
				 	<option value='0' <?php if(!isset($product['user_id']) || $product['user_id']==0)echo 'selected';?>>自已团队</option>
				 	<?php 
				 	if (isset($designerList) && $designerList):
				 		foreach ($designerList as $key => $val):
				 	?>
				 	<option value='<?php echo $key?>' <?php if($key==$product['user_id'])echo 'selected';?>><?php echo $val['username'];?></option>
				 	<?php 
				 		endforeach;
				 	endif;
				 	?>
				 	</select>
				</td>
      </tr>
     <?php endif;?>
      <tr class="hidden">
        <th>产品货号：</th>
        <td><input type="text" name="sn" class="input-text" value="<?php echo isset($product['sn']) ? $product['sn'] : null;?>"/><div class="infoShow">商品编号</div></td>
      </tr>
      <tr  style="display:none;">
        <th>成衣价：</th>
        <td><input type="text" name="sell_price" id="sell_price" class="input-text" value="<?php echo isset($product['sell_price']) ? $product['sell_price'] : null;?>"/></td>
      </tr>
      <tr style="display:none;">
        <th>定制价：</th>
        <td><input type="text" name="custom_price" id="custom_price" class="input-text" value="<?php echo isset($product['custom_price']) ? $product['custom_price'] : null;?>"/></td>
      </tr>
      <tr style="display:none;">
        <th>高级定制价：</th>
        <td><input type="text" name="advanced_price" id="advanced_price" class="input-text" value="<?php echo isset($product['advanced_price']) ? $product['advanced_price'] : null;?>"/></td>
      </tr>
      <tr >
        <th>市场价：</th>
        <td><input type="text" name="market_price" id="market_price" class="input-text" value="<?php echo isset($product['market_price']) ? $product['market_price'] : null;?>"/></td>
      </tr>
      <tr>
        <th>成本价：</th>
        <td><input type="text" name="cost_price" id="cost_price" class="input-text" value="<?php echo isset($product['cost_price']) ? $product['cost_price'] : null;?>"/></td>
      </tr>
      <tr>
        <th>重量：</th>
        <td><input type="text" name="weight" class="input-text" value="<?php echo isset($product['weight']) ? $product['weight'] : null;?>"/><div class="infoShow">克为单位</div></td>
      </tr>
      <tr class="hidden">
        <th>库存：</th>
        <td><input type="text" name="stock" class="input-text" value="<?php echo $product['stock'] ? $product['stock'] : 10;?>"/></td>
      </tr>
	  <tr style="display:none;">
		 <th>是否为预售产品：</th>
		  <td>
	  <input type='radio' name='product_type' onclick="productCss(0);" value='0' <?php if(isset($product['product_type']) || $product['product_type']==0) echo 'checked';?> > 否&nbsp;&nbsp;&nbsp;&nbsp;
	  <input type='radio' name='product_type' onclick="productCss(1);" value='1' <?php if($product['product_type'] > 0) echo 'checked';?> > 是</td>
    </tr>
	
	  <tr class="typecss" style="display:none;">
        <th>预付定金：</th>
        <td><input type="text" name="yufu_price" id="yufu_price" class="input-text" value="<?php echo $product['yufu_price'] ? $product['yufu_price'] : 1;?>"/></td>
      </tr>
	  
	  <tr class="typecss" style="display:none;">
        <th>预售开始时间：</th>
        <td>
		<input type="text" name="yushou_start_time" id="yushou_start_time" class="input-text" value="<?php echo $product['yushou_start_time'] ? date('Y-m-d',$product['yushou_start_time']) : date('Y-m-d',time());?>"/>
		<script type="text/javascript">
			Calendar.setup({
			weekNumbers: false,
		    inputField : "yushou_start_time",
		    trigger    : "yushou_start_time",
		    dateFormat: "%Y-%m-%d",
		    showTime: false,
		    minuteStep: 1,
		    onSelect   : function() {this.hide();}
			});
        </script>
		</td>
      </tr>
	  
	  <tr class="typecss" style="display:none;">
        <th>预售结束时间：</th>
        <td>
		<input type="text" name="yushou_end_time" id="yushou_end_time" class="input-text" value="<?php echo $product['yushou_end_time'] ? date('Y-m-d',$product['yushou_end_time']) : date('Y-m-d',strtotime('+10 day'));?>"/>
		<script type="text/javascript">
			Calendar.setup({
			weekNumbers: false,
		    inputField : "yushou_end_time",
		    trigger    : "yushou_end_time",
		    dateFormat: "%Y-%m-%d",
		    showTime: false,
		    minuteStep: 1,
		    onSelect   : function() {this.hide();}
			});
        </script>
		</td>
      </tr>
	  
	  <tr class="typecss" style="display:none;">
        <th>付尾款结束时间：</th>
        <td>
		<input type="text" name="weikuan_time" id="weikuan_time" class="input-text" value="<?php echo $product['weikuan_time'] ? date('Y-m-d',$product['weikuan_time']) : date('Y-m-d',strtotime('+20 day'));?>"/>
		<script type="text/javascript">
			Calendar.setup({
			weekNumbers: false,
		    inputField : "weikuan_time",
		    trigger    : "weikuan_time",
		    dateFormat: "%Y-%m-%d",
		    showTime: false,
		    minuteStep: 1,
		    onSelect   : function() {this.hide();}
			});
        </script>
		</td>
      </tr>
	  <tr class="typecss" style="display:none;">
      	<th>预售结束是否显示：</th>
      	<td>
	  		<input type='radio' name='yushou_display' value='1' <?php if(!isset($product['yushou_display']) || (isset($product['yushou_display']) && $product['yushou_display']==1)) echo 'checked';?>> 是&nbsp;&nbsp;&nbsp;&nbsp;
	  		<input type='radio' name='yushou_display' value='0' <?php if(isset($product['yushou_display']) && $product['yushou_display']==0) echo 'checked';?> > 否</td>
      </tr>
	  
      <tr>
        <th>等级积分：</th>
        <td><input type="text" name="rank_integral" class="input-text" value="<?php echo $product['rank_integral'] ? $product['rank_integral'] : -1;?>"/>-1为按产品销售价赠送积分</td>
      </tr>
      <tr>
        <th>消费积分：</th>
        <td><input type="text" name="integral" class="input-text" value="<?php echo $product['integral'] ? $product['integral'] : -1;?>"/>-1为按产品销售价赠送积分</td>
      </tr>
     <!-- <?php 
      if(isset($vocabularyList) && $vocabularyList):
      	foreach ($vocabularyList as $vocid => $voc_name):
      		if(empty($otherCategoryList[$vocid])) continue;
      ?>
      <tr>
        <th><?php echo $voc_name?>：</th>
        <td>
	        <?php foreach ($otherCategoryList[$vocid] as $cat):?>
        <input type="checkbox" name="category_product[]" value="<?php echo $cat['id'];?>" <?php if(in_array($cat['id'], $otherCategoryIds)) echo 'checked';?>/> <?php echo $cat['name'];?> 
	        <?php endforeach;?>
        </td>
      </tr>
      <?php
       endforeach;
      endif;
      ?>-->
      <tr class="hidden">
        <th>页面别名：</th>
        <td><input type="text" name="path_alias" id="path_alias" class="input-text" value="<?php echo $product['path_alias'] ? $product['path_alias'] : null;?>"/> <div class="infoShow">地址栏中展示的URL别名</div></td>
      </tr>
			<tr class="hidden">
        <th>页面模板：</th>
        <td><input type="text" name="template" id="template" class="input-text" value="<?php echo $product['template'] ? $product['template'] : null;?>"/> <div class="infoShow">该产品页使用的模板名称，不填为系统默认的模板</div></td>
      </tr>
			<tr>
      <tr class="hidden">
        <th>浏览量：</th>
        <td><input type="text" name="visit" id="visit" class="input-text" size="5" value="<?php echo $product['visit'] ? $product['visit'] : 0;?>"/></td>
      </tr>
			<tr class="hidden">
        <th>排序：</th>
        <td><input type="text" name="listorder" id="listorder" class="input-text" size="5" value="<?php echo $product['listorder'] ? $product['listorder'] : 0;?>"/></td>
      </tr>
      <tr>
        <th>赞次数：</th>
        <td><input type="text" name="product_up" id="product_up" disabled class="input-text" size="5" value="<?php echo $product['product_up'] ? $product['product_up'] : 0;?>"/></td>
      </tr>
     <tr>
        <th>踩次数：</th>
        <td><input type="text" name="product_down" id="product_down" disabled class="input-text" size="5" value="<?php echo $product['product_down'] ? $product['product_down'] : 0;?>"/></td>
      </tr>
     <tr>
        <th>产品类型：</th>
        <td>
        <input type='radio' name='is_sell' value='1' <?php if(!isset($product['is_sell']) || (isset($product['is_sell']) && $product['is_sell']==1)) echo 'checked';?>> 可以生产的商品&nbsp;&nbsp;&nbsp;&nbsp;
	  		<input type='radio' name='is_sell' value='0' <?php if(isset($product['is_sell']) && $product['is_sell']==0) echo 'checked';?> > 设计师的作品
	  </td>
      </tr>
    <tr style="display:none;">
     <th>是否显示：</th>
      <td>
	  <input type="text" name="display" value="1" />
    </tr>
    <tr>
		<th width="100">背景图片：</th>
		<td><input type="file" name="upimage" id="upimage" value="" size="50" />
		<input type="hidden" name="bg_img" value="<?php echo isset($product['bg_img']) && $product['bg_img'] ? $product['bg_img'] : null?>" />
		<?php if($product['bg_img']){?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<a href="javascript:showImage('<?php echo $product['bg_img'];?>')">【预览图片】</a><?php }?>
		</td>
	</tr>
	<tr style="display:none;">
     <th>限购：</th>
      <td>
	  <input type='radio' name='xianzhi' value="0" onclick="xiangou(1);" <?php if(isset($product['restriction']) || $product['restriction']==0) echo 'checked';?>> 否&nbsp;&nbsp;&nbsp;&nbsp;
	  <input type='radio' name='xianzhi' value="1" onclick="xiangou(0);" <?php if($product['restriction']>0) echo 'checked';?> > 是 &nbsp;&nbsp;&nbsp;&nbsp; <span id="dis" style="<?php echo $product['style'] ?>" ><input type="text" name="restriction" value="<?php echo $product['restriction'] ? $product['restriction'] : 0;?>" /></span></td>
    </tr>
    <tr>
		<th>产品相册：</th>
		<td>
		<input type="hidden" name="photo_name" id="photo_name" value="<?php echo isset($product_photo_ids) ? $product_photo_ids : null;?>"/>
		<input type="hidden" name="focus_photo" id="focus_photo" value="<?php echo $product['img'] ? $product['img'] : null;?>"/>
		<input type="hidden" name="small_img" id="small_img" value="<?php echo $product['small_img'] ? $product['small_img'] : null;?>"/>
		<input type="hidden" name="thumb" id="thumb" value=""/>
		<input type="text" name="upimage" value="" />
		<div class="upload_btn"><span id="upload"></span></div><label style="margin-left:20px">可以上传多张图片，上传默认第一张为产品图片，点击选择其他图片</label></td>
		</tr>
		<tr>
			<td></td><td id="show"></td>
		</tr>
		<tr>
			<td></td>
			<td id="show_list">
			<?php 
				if($photoList):
					foreach ($photoList as $file):
			?>
						<span id="a<?php echo $file['fid'];?>" class="pic">
								<img name="img_name" <?php if(strpos($product['img'],$file['img'])!==false){?>class="current"<?php }?> style="margin: 5px; opacity: 1;" src="<?php echo $file['thumb']?>" onclick="focus_img('<?php echo $file['img'];?>',this)">
								<br>
								<a id="<?php echo $file['fid'];?>" href="javascript:;" onclick="del_img(this.id)">删除</a>
							</span>
			<?php 
					endforeach;
				endif;
			?>
			</td>
		</tr>
</table>
</div>
<style type="text/css">
td.label {
    font-weight: bold;
    padding: 5px 1em;
    text-align: right;
    vertical-align: top;
}
.attr_value{float:left;padding:5px;width:100px;border: 1px solid #FFFFFF;}
.is_default,.attr_hover{border:1px solid #f00;}

#properties-table tr td{border-bottom:1px solid #eee;}
</style>
<div id="div_setting_2" class="contentList pad-10 hidden">
	<table width="100%" id="properties-table" align="center">
  	<tr>
    	<td class="label"><input id="check_all_attr" type="checkbox" onclick="selectAllAttribute();" name="all_attr"> 全选&nbsp;&nbsp;商品类型</td>
      <td>
      	<select name="model_id" id="modelid" onchange="select_attr(this.value)">
				 	<option value='0' selected>请选择商品类型</option>
				 	<?php 
				 	if (isset($modelList) && $modelList):
				 		foreach ($modelList as $key => $val):
				 	?>
				 	<option value='<?php echo $key?>' <?php if(isset($product['model_id']) && $key==$product['model_id']) echo 'selected';?>><?php echo $val;?></option>
				 	<?php 
				 		endforeach;
				 	endif;
				 	?>
				 </select><div class="infoShow">请选择商品的所属类型，进而完善此商品的属性,如果不选择第一个为默认选择项</div></td>
      </tr>
      <tr>
      	<td id="tbody-goodsAttr" colspan="2" style="padding:0"><?php echo isset($goods_attr_html) && $goods_attr_html ?  $goods_attr_html : null?></td>
      </tr>
  </table>
</div>
<!-- 
<div id="div_setting_3" class="contentList pad-10 hidden">
	<table width="100%" class="table_form contentWrap">
	<tr>
		<th width="150">适用会员等级：</th> 
		<td>
		<?php $rank_ids = $wholesale['rank_ids'] ? explode(',', $wholesale['rank_ids']) : null;?>
		<input type="checkbox" value="0" id="rank_id[]" <?php if(empty($rank_ids))echo 'checked';?> name="wholesale[rank_id][]"> 所有人 
		<?php 
			if(isset($rankList) && $rankList):
				foreach ($rankList as $rank):
		?>
		<input type="checkbox" value="<?php echo $rank['id']?>" <?php if(!is_null($rank_ids) && in_array($rank['id'], $rank_ids))echo 'checked';?> id="rank_id[]" name="wholesale[rank_id][]"> <?php echo $rank['name']?> 
		<?php 
				endforeach;
			endif;
		?>
		</td>
	</tr>
	<tr>
		<th>是否启用：</th> 
		<td><label>
		        <input type="radio" <?php if($wholesale==false || ($wholesale && $wholesale['display']==1))echo 'checked';?> value="1" name="wholesale[display]">
		        是</label>
		      <label>
		        <input type="radio" value="0" <?php if($wholesale && $wholesale['display']==0)echo 'checked';?> name="wholesale[display]">
		        否</label>
		 </td>
	</tr>
	</table>
	 <div class="bk15"></div>
	<hr />
	 <div class="bk15"></div>
	<div id="price-div">
	<table width="100%" class="table_form contentWrap">
	    <tbody>
	    <?php 
	    if($wholesale['prices']):
	    	$prices = unserialize($wholesale['prices']);
	    	foreach ($prices as $i => $list):
	    		if($i==0):
	    ?>
	     
	    <tr>
	    <td width="10%">&nbsp;</td>
	    <td> 数量 <input type="text" class="input-text" value="<?php echo $list['qty']?>" name="wholesale[qty][]"> </td>
	    <td> 价格 <input type="text" class="input-text" value="<?php echo $list['price']?>" name="wholesale[price][]"> </td>
	    <td>  <input type="button" onclick="addQuantityPrice(this, '0')" value=" + " class="button">  </td>
	    <td width="10%">&nbsp;</td>
	  </tr>
	  <?php else:?>
	  <tr>
	    <td width="10%">&nbsp;</td>
	    <td> 数量 <input type="text" class="input-text" value="<?php echo $list['qty']?>" name="wholesale[qty][]"> </td>
	    <td> 价格 <input type="text" class="input-text" value="<?php echo $list['price']?>" name="wholesale[price][]"> </td>
	    <td>  <input type="button" class="button" value=" - " onclick="dropQuantityPrice(this)" />  </td>
	    <td width="10%">&nbsp;</td>
	  </tr>
	  <?php	
	  			endif;
				endforeach;
	 		else:
	  ?>
	    <tr>
	    <td width="10%">&nbsp;</td>
	    <td> 数量 <input type="text" class="input-text" value="0" name="wholesale[qty][]"> </td>
	    <td> 价格 <input type="text" class="input-text" value="0" name="wholesale[price][]"> </td>
	    <td>  <input type="button" onclick="addQuantityPrice(this, '0')" value=" + " class="button">  </td>
	    <td width="10%">&nbsp;</td>
	  </tr>
	  <?php endif;?>
	  </tbody></table>
	</div>
</div>
 -->
<div id="div_setting_3" class="contentList pad-10 hidden">
<div id="related" class="box_Product main_right">
  <div id="tabs1" style=" margin-bottom:10px;">
    <ul style="height:28px;margin-top:10px;">
      <li><a href="javascript:void(0);" id="btn_list">列表</a></li>
      <li><a href="javascript:void(0);" id="btn_add">添加</a></li>
      <li><a href="javascript:void(0);" id="btn_select">过滤</a></li>
    </ul>
    <div id="list">
            <table  id="datalist">
              <tr class="subhead">
                <td width="8%">编号</td>
                <td width="30%">产品名称</td>
                <td width="40%"></td>
              </tr>
  <?php
  if( isset($productsRelatedList) && is_array($productsRelatedList)):
    foreach($productsRelatedList as $key => $prr):
  ?>
            <tr class="i<?php echo $key ?>">
              <td><a href="javascript:;" class="related_cancel" id="a_cancel_<?php echo $prr['pid'] ;?>" rel="<?php echo $prr['pid'] ;?>" >&nbsp;&nbsp;&nbsp;&nbsp;</a></td>
              <td><?php echo $prr['name'] ?></td>
              <td>
                <input class="isbothway" id="el-c9631-e855c" type="radio" name="isall_<?php echo $prr['pid'];?>" value="0" title="<?php echo $prr['pid'];?>" <?php if(!$prr['isbothway']) echo "checked";  ?> /> 单向关联&nbsp;
                <input class="isbothway" id="el-c9631-e855b" type="radio" name="isall_<?php echo $prr['pid'];?>" value="1" title="<?php echo $prr['pid'];?>" <?php if($prr['isbothway']==1) echo "checked";  ?>/> 双向关联
              </td>
            </tr>
  <?php
    endforeach;
    endif;
  ?>
            </table>
    </div>
    <div id="add" style="display:none"  style="clear:both;">
          <iframe id="ifr_add" width="100%" height=480 name="main" id="main" frameborder="0" scrolling=no src="<?php echo U('product/productrelated_list', array('pid' => isset($product['id']) ? $product['id'] : 0));?>"></iframe>
    </div>
  </div>
</div>



</div>

<div id="div_setting_4" class="contentList pad-10 hidden">
	<table width="100%" class="table_form contentWrap">
	<tr>
		<th width="150">全部预售数量：</th> 
		<td>
			<input type="text" name="yushou" id="yushou" onkeyup="yushou_num()" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />
		</td>
	</tr>
	<tr>
		<th>是否启用：</th> 
		<td><label>
		        <input type="radio" <?php if($size==false || ($size && $size['display']==1))echo 'checked';?> value="1" name="size[display]">
		        是</label>
		      <label>
		        <input type="radio" value="0" <?php if($size && $size['display']==0)echo 'checked';?> name="size[display]">
		        否</label>
		 </td>
	</tr>
	</table>
	 <div class="bk15"></div>
	<hr />
	 <div class="bk15"></div>
	<div id="price-div">
	<table width="100%" class="table_form contentWrap">
	    <tbody>
	    <?php 
	    if($size['prices']):
	    	$prices = unserialize($size['prices']);
	    	foreach ($prices as $i => $list):
	    		if($i==0):
	    ?>
	    
	    <tr>
	    <td width="10%">&nbsp;</td>
		<td> 尺码 <input type="text" class="input-text" value="<?php echo $list['size']?>" name="size[size][]"> </td>
	    <td> 预售数量 <input type="text" class="input-text total_fee" value="<?php echo $list['qty']?>" name="size[qty][]"> </td>
	    <td> 库存 <input type="text" class="input-text" value="<?php echo $list['stock']?>" name="size[stock][]"> </td>
		<td style="display:none"> <input type="text" class="input-text" value="<?php echo $list['num'] ? $list['num'] : 0;?>" name="size[num][]"> </td>
	    <td>  <input type="button" onclick="addProductSize(this, '0')" value=" + " class="button">  </td>
	    <td width="10%">&nbsp;</td>
	  </tr>
	  <?php else:?>
	  <tr>
	    <td width="10%">&nbsp;</td>
		<td> 尺码 <input type="text" class="input-text" value="<?php echo $list['size']?>" name="size[size][]"> </td>
	    <td> 预售数量 <input type="text" class="input-text total_fee" value="<?php echo $list['qty']?>" name="size[qty][]"> </td>
	    <td> 库存 <input type="text" class="input-text" value="<?php echo $list['stock']?>" name="size[stock][]"> </td>
		<td style="display:none"> <input type="text" class="input-text" value="<?php echo $list['num'] ? $list['num'] : 0;?>" name="size[num][]"> </td>
	    <td>  <input type="button" class="button" value=" - " onclick="dropProductSize(this)" />  </td>
	    <td width="10%">&nbsp;</td>
	  </tr>
	  <?php	
	  			endif;
				endforeach;
	 		else:
	  ?>
	    <tr>
	    <td width="10%">&nbsp;</td>
		<td> 尺码 <input type="text" class="input-text" value="0" name="size[size][]"> </td>
	    <td> 预售数量 <input type="text" class="input-text total_fee" value="0" name="size[qty][]"> </td>
	    <td> 库存 <input type="text" class="input-text" value="0" name="size[stock][]"> </td>
		<td style="display:none"><input type="text" class="input-text" value="0" name="size[num][]"> </td>
	    <td>  <input type="button" onclick="addProductSize(this, '0')" value=" + " class="button">  </td>
	    <td width="10%">&nbsp;</td>
	  </tr>
	  <?php endif;?>
	  </tbody></table>
	</div>
</div>
	  
	  <?php 
$i = $base_tab+1;
	if(isset($languageList) && $languageList):
		foreach ($languageList as $language_id => $language_name):
?>
<div id="div_setting_<?php echo $i;?>" class="contentList pad-10 hidden">
	<table width="100%" class="table_form ">
      <tr>
        <th>产品名称：</th>
        <td><input type="text" name="product[<?php echo $language_id;?>][name]" id="product_name_<?php echo $language_id;?>" class="input-text" size='60' value="<?php echo isset($product['name']) ? $product['name'] : null;?>"/></td>
      </tr>
      <tr>
        <th>简介：</th>
        <td><textarea name="product[<?php echo $language_id;?>][summary]" style="width: 715px; height: 80px;"><?php echo isset($product['items'][$language_id]['summary']) ? $product['items'][$language_id]['summary'] : null;?></textarea></td>
      </tr>
      <tr>
        <th>参数说明：</th>
        <td><textarea name="product[<?php echo $language_id;?>][content]" class="editor" style="width: 715px; height: 80px;"><?php echo isset($product['items'][$language_id]['content']) ? $product['items'][$language_id]['content'] : null;?></textarea></td>
      </tr>
      <tr>
        <th>描述：</th>
        <td><textarea name="product[<?php echo $language_id;?>][description]" class="editor"><?php echo isset($product['content']) ? $product['content'] : null;?></textarea></td>
      </tr>
      <tr>
	      <th>网页标题：</th>
	      <td><input name='product[<?php echo $language_id;?>][meta_title]' class="input-text" type='text' value='<?php echo isset($product['items'][$language_id]['meta_title']) ? $product['items'][$language_id]['meta_title'] : null;?>' style="width:50%;"><div class="infoShow">针对搜索引擎设置的标题</div></td>
    </tr>
    <tr>
      <th>网页关键词：</th>
      <td><textarea name='product[<?php echo $language_id;?>][meta_keywords]' style="width:50%;height:40px"><?php echo isset($product['items'][$language_id]['meta_keywords']) ? $product['items'][$language_id]['meta_keywords'] : null;?></textarea><div class="infoShow">关键字中间用半角逗号隔开</div></td>
    </tr>
    <tr>
      <th>网页描述：</th>
      <td><textarea name='product[<?php echo $language_id;?>][meta_description]' style="width:50%;height:50px"><?php echo isset($product['items'][$language_id]['meta_description']) ? $product['items'][$language_id]['meta_description'] : null;?></textarea><div class="infoShow">针对搜索引擎设置的网页描述</div></td>
    </tr>
	</table>
</div>
<?php 
		$i++;
		endforeach;
	endif;
?>

 <div class="bk15"></div>
    <input name="dosubmit" type="submit" value="提交" class="button">
</div>
</div>
</form>
</body>
</html>
<script type="text/javascript">
<!--
var goods_id = <?php echo isset($product['id']) ? $product['id'] : 0;?>;
var designer_product_id = <?php echo isset($product['designer_product_id']) ? $product['designer_product_id'] : 0;?>;

$(function(){
	$('.attr_value').mouseover(function(){
		$(this).addClass('attr_hover');
		}).mouseout(function(){
			$(this).removeClass('attr_hover');
		}).click(function(){
			var tdobj = $(this).parent('td');
			var sub_input_obj = $(this).find('input');
			var chk = sub_input_obj.attr('checked');
			tdobj.children('.attr_value').removeClass('is_default');
			if(chk==true){
				$(this).addClass('is_default');
				tdobj.children('input:last').val(sub_input_obj.val());
			}
		});
	$('.attr_value input').click(function(){
			if($(this).attr('checked') == false){
				$(this).closest('td').children('input:last').val(0);
			}
	});
	
	product_type = '<?php echo isset($product['product_type']) ? $product['product_type'] : null?>';
  	productCss(product_type);
});

/**
 * 添加扩展分类
 */
function addOtherCat(conObj)
{
    var sel = document.createElement("SELECT");
    var selCat = document.forms['myform'].elements['catid'];

    for (i = 0; i < selCat.length; i++)
    {
        var opt = document.createElement("OPTION");
        opt.text = selCat.options[i].text;
        opt.value = selCat.options[i].value;
        if ($.browser.msie)
        {
            sel.add(opt);
        }
        else
        {
            sel.appendChild(opt);
        }
    }
    conObj.appendChild(sel);
    sel.name = "other_cat[]";
    sel.onChange = function() {checkIsLeaf(this);};
}

function select_model(){
	catid = $('#catid').val();
	$.get('<?php echo U('product/select_model_ajax');?>',{catid:catid},function(data){
			if(data){
				html ="<option value='0' selected>请选择属性类型</option>";
				<?php 
					 	if (isset($modelList) && $modelList){
					 		foreach ($modelList as $key => $val){
					 	?>
						if(data == <?php echo $key?>){
							html += '<option value="'+<?php echo $key;?>+'" selected>'+"<?php echo $val;?>"+'</option>';
						}else{
							html += '<option value="'+<?php echo $key;?>+'">'+"<?php echo $val;?>"+'</option>';
						}
					 	<?php 
					 		}
					 	}
					 	?>
			 	$('#modelid').html(html);
			 	select_attr(data);
			}
		});
}

function select_designer_product(designer_id){
	if(designer_id == 0)return false;
	$.getJSON('<?php echo U('product/select_designer_product_ajax');?>',{did:designer_id},function(data){
			if(data){
				html ="<option value='0' selected>选择设计师作品</option>";
				for(var i in data){
						if(data[i]['designer_product_id'] == designer_product_id){
							html += '<option value="'+data[i]['designer_product_id']+'" selected>'+data[i]['designer_name']+'</option>';
						}else{
							html += '<option value="'+data[i]['designer_product_id']+'">'+data[i]['designer_name']+'</option>';
						}
				}
			 	$('#designer_product_id').html(html);
			}
		});
}
function select_attr(modelid){
	$.get('<?php echo U('product/get_attribute_ajax');?>',{is_ajax:1,model_id:modelid,pid:goods_id},function(data){
		if(data){
			$('#tbody-goodsAttr').html(data);
		}
		$('.attr_value').mouseover(function(){
			$(this).addClass('attr_hover');
			}).mouseout(function(){
				$(this).removeClass('attr_hover');
			}).click(function(){
				var tdobj = $(this).parent('td');
				var sub_input_obj = $(this).find('input');
				var chk = sub_input_obj.attr('checked');
				tdobj.children('.attr_value').removeClass('is_default');
				if(chk==true){
					$(this).addClass('is_default');
					tdobj.children('input:last').val(sub_input_obj.val());
				}
			});
			$('.attr_value input').click(function(){
					if($(this).attr('checked') == false){
						$(this).closest('td').children('input:last').val(0);
					}
			});
	});
}
var swfu;
window.onload = function () {
	swfu = new SWFUpload({
		// Backend Settings
		upload_url: "<?php echo U('product/swfupload_ajax');?>",
		post_params: {"PHPSESSID": "<?php echo session_id();?>"},

		file_size_limit : "2 MB",	// 2MB
		file_types : "*.jpg;*.jpge;*.png;*.gif",
		file_types_description : "JPG Images",
		file_upload_limit : "0",
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess,
		upload_complete_handler : uploadComplete,

		// Button Settings
		button_placeholder_id : "upload",
		button_width: 50,
		button_height: 21,
		button_text : '浏览...',
		button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
		button_cursor: SWFUpload.CURSOR.HAND,

		// Flash Settings
		flash_url : "/statics/js/swfupload/swfupload.swf",

		custom_settings : {
			upload_target : "show"
		},
		// Debug Settings
		debug: false
	});
};
function show_link(img)
{
	window.top.art.dialog({title:'图片链接', id:'link', iframe:'<?php echo U('product/public_show_photo_link_ajax');?>&img='+img,width:'600px',height:'200px'},function(){window.top.art.dialog({id:'link'}).close()});
}
function del_img(id)
{
	//删除数组元素.
	Array.prototype.remove=function(dx)
	{
	    if(isNaN(dx)||dx>this.length){return false;}
	    for(var i=0,n=0;i<this.length;i++)
	    {
	        if(this[i]!=this[dx])
	        {
	            this[n++]=this[i]
	        }
	    }
	    this.length-=1
	}
	//在数组中获取指定值的元素索引
	Array.prototype.getIndexByValue= function(value)
	{
	    var index = -1;
	    for (var i = 0; i < this.length; i++)
	    {
	        if (this[i] == value)
	        {
	            index = i;
	            break;
	        }
	    }
	    return index;
	}
	var photo_name = $('#photo_name').val();
	photo_name = photo_name.substring(0,photo_name.length-1);
	var arr = photo_name.split(',');
	var key = 0;
	for(var i=0;i<arr.length;i++){
		if(arr[i].indexOf(id)>0){
			key = i;
		}
	}
	arr.remove(key);
	if(arr.length>0)
	{
		//如果没有全部删除则不为空
		$('#photo_name').val(arr.join(',')+',');
		$("#a"+id).remove();
		var focus_photo = $('#focus_photo').val();
		var is_curr = 0;//是否为选择图片
		$('#show_list > .pic > img').each(function(index){
			if($(this).hasClass('current')){
				is_curr=1;
			}
		});
		
		if(is_curr==1)return true;
		//重新选择第一个为默认图片
		curr_new_id = arr[0];

		var obj_curr_img = $("#a"+curr_new_id+'>img');
		obj_curr_img.addClass('current');
		$('#small_img').val(obj_curr_img.attr('src'));
		$('#focus_photo').val(obj_curr_img.attr('original'));

	}else{
		//如果图片全部删除则值为空
		$('#photo_name').val("");
		$('#focus_photo').val("");
		$('#small_img').val("");
		$("#a"+id).remove();
	}
}
function focus_img(little,obj)
{
	$('#focus_photo').val(little);
	$("img[name='img_name']").removeClass('current');
	obj.className = 'current';
}

//批发JS
/**
 * @param object buttonObj
 * @param int    tableIndex
 */
function addQuantityPrice(buttonObj, tableIndex)
{
  var tableObj = buttonObj.parentNode.parentNode.parentNode.parentNode;
  var newRow = tableObj.insertRow(-1);
  var cell1 = newRow.insertCell(-1);
  var cell2 = newRow.insertCell(-1);
  var cell3 = newRow.insertCell(-1);
  var cell4 = newRow.insertCell(-1);
  var cell5 = newRow.insertCell(-1);
  
  cell1.innerHTML = '&nbsp;';
  cell2.innerHTML = ' 数量 <input class="input-text" name="wholesale[qty][]" type="text" value="" /> ';
  cell3.innerHTML = ' 价格 <input class="input-text" name="wholesale[price][]" type="text" value="" /> ';
  cell4.innerHTML = ' <input type="button" class="button" value=" - " onclick="dropQuantityPrice(this)" />';
  cell5.innerHTML = '&nbsp;';
  
}

//尺码JS
/**
 * @param object buttonObj
 * @param int    tableIndex
 */
function addProductSize(buttonObj, tableIndex)
{
  var tableObj = buttonObj.parentNode.parentNode.parentNode.parentNode;
  var newRow = tableObj.insertRow(-1);
  var cell1 = newRow.insertCell(-1);
  var cell2 = newRow.insertCell(-1);
  var cell3 = newRow.insertCell(-1);
  var cell4 = newRow.insertCell(-1);
  var cell5 = newRow.insertCell(-1);
  var cell6 = newRow.insertCell(-1);
  
  cell1.innerHTML = '&nbsp;';
  cell2.innerHTML = ' 尺码 <input class="input-text" name="size[size][]" type="text" value="" /> ';
  cell3.innerHTML = ' 预售数量 <input class="input-text total_fee" name="size[qty][]" type="text" value="" /> ';
  cell4.innerHTML = ' 库存 <input class="input-text" name="size[stock][]" type="text" value="" /> ';
  cell5.innerHTML = ' <input type="button" class="button" value=" - " onclick="dropProductSize(this)" />';
  cell6.innerHTML = '&nbsp;';
  
}

//预售数量
function yushou_num()
{
	var temp;

	temp = $("#yushou").val();
	temp = temp.replace(/[^\d]/g,'');
	$("#yushou").val(temp);

	temp = $("#yushou").val();
	$(".total_fee").val(temp);
}


/**
 * @param object buttonObj
 */
function dropProductSize(buttonObj)
{
  var trObj = buttonObj.parentNode.parentNode;
  var tableObj = trObj.parentNode.parentNode;
  tableObj.deleteRow(trObj.rowIndex);
}

/**
 * @param object buttonObj
 */
function dropQuantityPrice(buttonObj)
{
  var trObj = buttonObj.parentNode.parentNode;
  var tableObj = trObj.parentNode.parentNode;
  tableObj.deleteRow(trObj.rowIndex);
}

function addSpec(obj)
{
    var src   = obj.parentNode.parentNode;
    var idx   = rowindex(src);
    var tbl   = document.getElementById('attrTable');
    var row   = tbl.insertRow(idx + 1);
    var cell1 = row.insertCell(-1);
    var cell2 = row.insertCell(-1);
    var regx  = /<a([^>]+)<\/a>/i;

    cell1.className = 'label';
    cell1.innerHTML = src.childNodes[0].innerHTML.replace(/(.*)(addSpec)(.*)(\[)(\+)/i, "$1removeSpec$3$4-");
    cell2.innerHTML = src.childNodes[1].innerHTML.replace(/readOnly([^\s|>]*)/i, '');
}

/**
 */
function removeSpec(obj)
{
    var row = rowindex(obj.parentNode.parentNode);
    var tbl = document.getElementById('attrTable');

    tbl.deleteRow(row);
}

function xiangou(id)
{
	if(id >0)
		$('#dis').css({display:"none"});
	else
		$('#dis').css({display:"block"});
}

function productCss(id)
{	
	$(".typecss").css('display',(id == 1) ? "" : "none");
}

//选择所有属性
function selectAllAttribute()
{
		var chk = $('#check_all_attr').attr('checked');
			$('#tbody-goodsAttr').find('input[type=checkbox]').each(function(){
				$(this).attr('checked',chk);
			});
}

//关联
    $('#btn_list').click(function(){
      $('#list').show();
      $('#add').hide();
    });
    $('#btn_add').click(function(){
      $('#list').hide();
      $('#add').show();
      $('#ifr_add').attr('src', '<?php echo U('product/productrelated_add')?>');
    });
    $('#btn_select').click(function(){
      $('#list').hide();
      $('#add').show();
      $('#ifr_add').attr('src', '<?php echo U('product/productrelated_select')?>');
    });
    
//-->
</script>
